package com.central.common.feign.fallback;

import com.central.common.feign.UserAccountService;
import com.central.common.model.LoginAppUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * userService降级工场
 *
 * @author ly
 * @email 664162337@qq.com
 * @date 2020/9/25 15:02
 */
@Slf4j
public class UserAccountServiceFallbackFactory implements FallbackFactory<UserAccountService> {

    @Override
    public UserAccountService create(Throwable throwable) {
        return new UserAccountService() {
            @Override
            public LoginAppUser findByUsername(String username) {
                log.error("通过 username 查询用户异常:{}", username, throwable);
                return new LoginAppUser();
            }

            @Override
            public LoginAppUser findByUserId(String userId) {
                log.error("通过 userId 查询用户异常:{}", userId, throwable);
                return new LoginAppUser();
            }
        };
    }
}
